package com.haitonghop.utils.sqllite.helper;

import com.haitonghop.utils.Logger;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class SQLiteHaiBLMetalDataCachedHelper extends SQLLiteHelper {

	public static final String TABLE_COMICS = "comiccached";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_CAPTION = "_caption";
	public static final String COLUMN_IMAGESPATH = "_imagePath";
	public static final String COLUMN_TIMESTAMP = "_lastWriteable";	
	public static final String COLUMN_TOPIC_ID = "_topicid";

	// Database creation sql statement
	private static final String DATABASE_CREATE = "create table "
			+ TABLE_COMICS + "(" + COLUMN_ID + " text primary key , "
			+ COLUMN_CAPTION + " text not null," 
			+ COLUMN_IMAGESPATH + " text not null," 
			+ COLUMN_TIMESTAMP + " text not null," 
			+ COLUMN_TOPIC_ID + " id not null);";

	public SQLiteHaiBLMetalDataCachedHelper(Context context) {		
		super(context);
		Logger.logMe(">>>>>>>>>>>>>>>>> SQLiteHaiBLMetalDataCachedHelper");
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		Logger.logMe(">>>>>>>>>>>>>>>>> onCreate = "+DATABASE_CREATE);
		database.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(SQLiteHaiBLMetalDataCachedHelper.class.getName(),
				"Upgrading database from version " + oldVersion + " to "
						+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_COMICS);
		onCreate(db);
	}

}
